﻿<%@ Page Title="Transfer Shipment" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="TransferShipment.aspx.cs" Inherits="VSM.TransferShipment" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function isNumberKey(sender, evt) {
            var txt = sender.value;
            var dotcontainer = txt.split('.');
            var charCode = (evt.which) ? evt.which : event.keyCode;
            if (!(dotcontainer.length == 1 && charCode == 46) && charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;
        }
        function OpenItemPopup() {
            var url = "../../ItemPopup.aspx?itmgrp=104";
            Main.openCustomDialog(url, 600, 610, "Item Master Data");
        }
        function OpenWhs(whsType, title) {
            var url = "../../WhsPopup.aspx?id=" + whsType;
            Main.openCustomDialog(url, 600, 610, title);
        }
        function OpenBP() {
            var url = "../../BPPopup.aspx?CardType=C";
            Main.openCustomDialog(url, 600, 610, "Business Partner List");
        }
        function OpenDocList(docktype, TransferType, title, status) {
            var url = "../../DocumentList.aspx?DocType=" + docktype + "&Status=" + status + "&TransferType=" + TransferType
            Main.openCustomDialog(url, 800, 610, title);
        }

        function OpenOSRI(itemCode, whsCode) {
            var url = "../../SerialNumberPopup.aspx?ItemCode=" + itemCode;
            url += "&WhsCode=" + whsCode;
            Main.openCustomDialog(url, 800, 610, "VIN Number List");
        }

        function OpenMain(printType) {
            var docentry = $("#<%= txtTransferNo.ClientID %>").val();
            var dimensions = 'directories=no,titlebar=yes,toolbar=no,location=1,status=yes,menubar=no,scrollbars=yes,resizable=yes,height=620 ,width= 900 ';
            if (navigator.appName != "Microsoft Internet Explorer") {
                window.opener = self;
            }
            else {
                window.opener = true;
            }

            window.open('', '_self');
            var newWindow = window.open('../Printing/FormPrinting.aspx?DocEntry=' + docentry + '&DocType=67&PrintType=' + printType, '_blank', dimensions);
            if (isIE() == 8) {
                newWindow.location.href = '../Printing/FormPrinting.aspx?DocEntry=' + docentry + '&DocType=67&PrintType=' + printType
            }
            window.moveTo(0, 0);
            window.resizeTo(screen.width, screen.height - 100);
        }
        function isIE() {
            var myNav = navigator.userAgent.toLowerCase();
            return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
        }

    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="hdnIsUpdate" runat="server" />
                <asp:HiddenField ID="hdnStatus" runat="server" />
                <asp:HiddenField ID="hdnBaseType" runat="server" />
                <h2>
                    &nbsp;<asp:Label ID="lblTitle" runat="server" Text="Transfer Shipment"></asp:Label>
                </h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />
                    <table border="0" width="100%" style="background-color: #D1D4D8; font-weight: bold;">
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Transfer No.:
                            </td>
                            <td>
                                <asp:TextBox ID="txtTransferNo" runat="server" BackColor="#E6E6E6" ReadOnly="True"
                                    Width="122px"></asp:TextBox>
                            </td>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;" width="100px">
                                Transfer Type:
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="ddl_TransferType" runat="server" Enabled="False">
                                    <asp:ListItem Value="0">Transfer Receipt</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td align="right">
                                <asp:Button ID="btnDocList" runat="server" BorderStyle="Solid" OnClientClick="OpenDocList('67', '0','Transfer Shipment List'); return false;"
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Text="List" Width="60px" />
                            </td>
                        </tr>
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; width: 150px">
                                Posting Date:
                            </td>
                            <td style="width: 250px">
                                <asp:TextBox ID="txtPostingDate" runat="server" AutoPostBack="True" OnTextChanged="txtPODate_TextChanged"></asp:TextBox>
                                <asp:ImageButton ID="imgPostingDate" runat="Server" AlternateText="Click to show calendar"
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtPostingDate"
                                    PopupButtonID="imgPostingDate" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <asp:Label ID="lblPosDateRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                From Whs.:
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtFromWhsCode" runat="server" BackColor="#E6E6E6" ReadOnly="True"
                                    Width="96px"></asp:TextBox>
                                <asp:TextBox ID="txtFromWhsName" runat="server" Width="250px"></asp:TextBox>
                                <asp:Button ID="btnSelectFromWhs" runat="server" OnClientClick="OpenWhs('from', 'From Warehouse List'); return false;"
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;
                                    font-weight: bold" Text="..." Width="22px" />
                                <asp:Label ID="lblFrmWhsRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                Document Date:
                            </td>
                            <td valign="top">
                                <asp:TextBox ID="txtDocDate" runat="server"></asp:TextBox>
                                <asp:ImageButton ID="imgDocDate" runat="Server" AlternateText="Click to show calendar"
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                                <cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtDocDate"
                                    PopupButtonID="imgDocDate" Format="dd/MM/yyyy">
                                </cc1:CalendarExtender>
                                <asp:Label ID="lblDocDateRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom;">
                                To Transit:
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtToWhsCode" Text="9999" runat="server" BackColor="#E6E6E6" ReadOnly="True"
                                    Width="96px"></asp:TextBox>
                                <asp:TextBox ID="txtToWhsName" runat="server" Width="250px"></asp:TextBox>
                                <asp:Button ID="btnSelectToWhs" runat="server" OnClientClick="OpenWhs('to', 'To Transit List'); return false;"
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;
                                    font-weight: bold" Text="..." Width="22px" />
                                <asp:Label ID="lblToWhsRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <table id="Table2" width="100%" style="font-weight: bold">
                        <tr>
                            <td class="FormLineItemAlt" style="width: 150px;">
                                <asp:Label ID="lblCustomerInfo" runat="server" Text="Customer:"></asp:Label>
                            </td>
                            <td class="FormLineItemAlt" style="white-space: nowrap;" valign="middle">
                                <asp:TextBox ID="txtCustomerCode" runat="server" ReadOnly="True" Width="96px" BackColor="#E6E6E6"></asp:TextBox>
                                <asp:TextBox ID="txtCustomerName" runat="server" Width="250px"></asp:TextBox>
                                <asp:Button ID="btnSelectBP" runat="server" OnClientClick="OpenBP(); return false;"
                                    Text="..." Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;
                                    font-weight: bold" Width="22px" />
                                <asp:Label ID="lblCustomerRequired" runat="server" ForeColor="Red" Text="*"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td class="FormLineItem" style="width: 100px;">
                                <asp:Label ID="lblConPersonName" Text="Contact Person:" runat="server"></asp:Label>
                            </td>
                            <td class="FormLineItem" valign="middle">
                                <asp:TextBox ID="txtContactPerson" runat="server" MaxLength="100" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td class="FormLineItemAlt" valign="middle" colspan="2">
                                <asp:Button ID="btnAddItems" runat="server" Enabled="False" 
                                    onclick="btnAddItems_Click" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Text="Add vehicle" Width="75px" />
                                <asp:Button ID="btnAddAccessories" runat="server" Text="Add accessories" OnClientClick="OpenItemPopup(); return false;"
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;"
                                    BorderStyle="Solid" Width="110px" />
                            </td>
                        </tr>
                    </table>
                    <hr />
                    <div style="width: 100%">
                        <asp:GridView ID="grvWTR1" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                            BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                            HeaderStyle-Height="27px" OnRowCreated="grvWTR1_RowCreated" 
                            CellSpacing="2" HeaderStyle-VerticalAlign="Middle"
                            AllowPaging="True" OnPageIndexChanging="grvWTR1_PageIndexChanging" 
                            PageSize="20" OnRowDataBound="grvWTR1_RowDataBound">
                            <PagerSettings Mode="NumericFirstLast" />
                            <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                            <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                            <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                            <Columns>
                                <asp:CommandField HeaderText="Action" ShowDeleteButton="True" ShowEditButton="False"
                                    Visible="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                                    ItemStyle-Width="70px" />
                                <asp:TemplateField HeaderText="Action">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" TabIndex="-1" OnClick="lnkDelete_Click"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="#">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("No") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Model">
                                    <ItemStyle HorizontalAlign="Center" Width="150px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlModel" AutoPostBack="true" onselectedindexchanged="ddlModel_SelectedIndexChanged" 
                                            style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnModel" runat="server" Value='<%# Bind("U_Model") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Product">
                                    <ItemStyle HorizontalAlign="Center" Width="170px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlProduct" AutoPostBack="true" onselectedindexchanged="ddlProduct_SelectedIndexChanged" 
                                            style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnProduct" runat="server" Value='<%# Bind("U_Product") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Color">
                                    <ItemStyle HorizontalAlign="Center" Width="190px" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlColor" AutoPostBack="true" onselectedindexchanged="ddlColor_SelectedIndexChanged" style="width: 98%;" runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnColor" runat="server" Value='<%# Bind("U_Color") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Item Code" Visible="false">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblItemCode" runat="server" Text='<%# Bind("ItemCode") %>' BorderStyle="none"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Item Name">
                                    <ItemStyle HorizontalAlign="left" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <HeaderTemplate>
                                        <asp:label ID="lblHeaderItemName" runat="Server" Text="Item Name" />
                                        <asp:label ID="lblItemNameRequired" runat="server" Font-Bold="true" Text="*" ForeColor="Red" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="txtItemName" runat="server" Text='<%# Bind("Dscription") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Quantity">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="100px" />
                                    <HeaderTemplate>
                                        <asp:label ID="lblHeaderQty" runat="Server" Text="Quantity" />
                                        <asp:label ID="lblQtyRequired" runat="server" Font-Bold="true" Text="*" ForeColor="Red" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity" runat="server" Width="97%" Text='<%# Eval("Quantity")%>'
                                            AutoPostBack="true" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right"
                                            OnTextChanged="txtOrderQuantity_OnTextChanged" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="VIN Number">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle VerticalAlign="Middle" Width="170px" />
                                    <HeaderTemplate>
                                        <asp:label ID="lblHeaderVINNumber" runat="Server" Text="VIN Number" />
                                        <asp:label ID="lblVINNumberRequired" runat="server" Font-Bold="true" Text="*" ForeColor="Red" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkOSRI" runat="server" OnClick="lnkOSRI_Click">
                                        <img src="../../skin/icon/link.png" alt="icon"/>
                                            <%--<asp:Image ID="imgOSRI" runat="server" ImageUrl="/skin/icon/link.png" />--%></asp:LinkButton>
                                        <asp:TextBox ID="txtDistNumber" runat="server" BackColor="Transparent" ReadOnly="true"
                                            Width="80%" Style="text-align: center" Text='<%# Bind("DistNumber") %>' BorderStyle="none" />
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="BaseEntry" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" Width="0px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblBaseEntry" runat="server" Text='<%# Bind("BaseEntry") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="BaseLine" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" Width="0px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblBaseLine" runat="server" Text='<%# Bind("BaseLine") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="BaseType" Visible="false">
                                    <HeaderStyle VerticalAlign="Middle" Width="0px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblBaseType" runat="server" Text='<%# Bind("BaseType") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#6095C9" Font-Bold="true" ForeColor="#ffffff" Font-Overline="False"
                                Height="27px" VerticalAlign="Bottom" />
                            <EmptyDataTemplate>
                                <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all"
                                    cellspacing="2" cellpadding="2">
                                    <tr valign="middle" style="height: 27px; color: white; font-weight: bold; text-decoration: none;
                                        background-color: rgb(96, 149, 201);">
                                        <th>
                                            <span>Action</span>
                                        </th>
                                        <th>
                                            <span>#</span>
                                        </th>
                                        <th>
                                            <span>Item Code</span>
                                        </th>
                                        <th>
                                            <span>Item Name</span>
                                        </th>
                                        <th>
                                            <span>Model</span>
                                        </th>
                                        <th>
                                            <span>Color</span>
                                        </th>
                                        <th>
                                            <span>UoM</span>
                                        </th>
                                        <th>
                                            <span>Quantity</span>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td colspan="9">
                                            <span>No Data</span>
                                        </td>
                                    </tr>
                                </table>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </div>
                    <hr width="100%" />
                </div>
                <table width="100%" border="0">
                    <tr>
                        <td valign="top" style="width: 50%;">
                            <table>
                                <tr>
                                    <td style="width: 20%;">
                                        <strong>Remarks :</strong>
                                    </td>
                                    <td style="width: 80%;">
                                        <asp:TextBox runat="server" ID="txtRemarks" Height="71px" Width="100%" TextMode="MultiLine"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style="margin-left: 5px; width: 99%;">
                                <hr />
                            </div>
                            <table style="width: 100%">
                                <tr>
                                    <td>
                                        <asp:Button ID="btnSave" runat="server" Text="Save" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" OnClick="btnSave_Click" Width="60px"
                                            OnClientClick="return confirm('Are you sure?' After saved, you cannot edit anythings in this Transfer.);" BorderStyle="Solid" />
                                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" BorderStyle="Solid" OnClick="btnCancel_Click" Width="60px" 
                                            OnClientClick="return confirm('Are you sure? After Canced, you cannot edit anythings in this Inventory Transfer.');" />
                                        <asp:Button ID="btnPrintDisplayTransfer" runat="server" BorderStyle="Solid" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" Text="Print Display Transfer" 
                                            Width="140px" onclick="btnPrintDisplayTransfer_Click" Visible="False" />

                                        <asp:Button ID="btnPrintVehicleTransfer" runat="server" BorderStyle="Solid" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" Text="Print Transfer" 
                                            Width="130px" onclick="btnPrintVehicleTransfer_Click" />

                                        <asp:Button ID="btnPrintTransferInvoice" runat="server" BorderStyle="Solid" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" 
                                            Text="Print Transfer Invoice" Width="140px" 
                                            onclick="btnPrintTransferInvoice_Click" Visible="False" />

                                        <asp:Button ID="btnLastRecord" runat="server" BorderStyle="Solid" OnClick="btnLastRecord_Click"
                                            Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;
                                            color: White;" Text="&gt;&gt;" ToolTip="Last record" Width="40px" />
                                    </td>
                                    <td style="width: 200px;" align="right">
                                        <asp:Button ID="btnCopyFrom" runat="server" Text="Copy from Transfer Request" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" OnClientClick="OpenDocList('1250000001', 'Inventory Transfer Request', 'O'); return false;"
                                            BorderStyle="Solid" Width="175px" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label ID="lblError" runat="server" Visible="False" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                 <asp:PostBackTrigger  ControlID="btnPrintDisplayTransfer" />
                 <asp:PostBackTrigger  ControlID="btnPrintVehicleTransfer" />
                 <asp:PostBackTrigger  ControlID="btnPrintTransferInvoice" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
